<template>
	<view class="process-edit-bg">
		<view class="process-num-bg">
			<view class="title-txt">工艺名称</view>
			<view class="num-txt">
				<input placeholder="请输入" v-model="proceeName"/>
			</view>
		</view>

		<view class="param-set-bg">
			<scroll-view class="tab-bg" scroll-y="true">
				<view v-for="(item, index) in tabList" :key="index"
					:class="currentTabPosition==item.tabIndex?'tab-item-selected-bg':'tab-item-unselect-bg'"
					@click="chooseTab(item, index)">
					<view class="tab-txt">{{item.name}}</view>
				</view>
			</scroll-view>
			
			<scroll-view class="content-edit-bg" scroll-y="true">
				<view v-if="currentTabPosition==tabList[0].tabIndex">
					<view class="content-tab-title-bg">
						引弧参数
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">引弧时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="arcStart.arcDuration" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">引弧电流(A):</view>
						<input class="param-value-txt" type="digit" v-model="arcStart.electricity" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">引弧电压(V):</view>
						<input class="param-value-txt" type="digit" v-model="arcStart.voltage.value" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">引弧电压修正值(%):</view>
						<input class="param-value-txt" type="digit" v-model="arcStart.voltage.correction" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">引气时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="arcStart.gasDuration" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">缓升时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="arcStart.riseFall" />
					</view>
				</view>
			
				<view v-if="currentTabPosition==tabList[1].tabIndex">
					<view class="content-tab-title-bg">
						收弧参数
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">收弧时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="arcEnd.arcDuration" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">收弧电流(A):</view>
						<input class="param-value-txt" type="digit" v-model="arcEnd.electricity" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">收弧电压(V):</view>
						<input class="param-value-txt" type="digit" v-model="arcEnd.voltage.value" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">收弧电压修正值(%):</view>
						<input class="param-value-txt" type="digit" v-model="arcEnd.voltage.correction" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">引气时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="arcEnd.gasDuration" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">缓升时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="arcEnd.riseFall" />
					</view>
				</view>
			
				<view v-if="currentTabPosition==tabList[2].tabIndex">
					<view class="content-tab-title-bg">
						焊接参数
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">焊接参数类型:</view>
						<view class="param-picker-bg">
							<picker mode="selector" :range="param3WeldingTypeList" range-key="name" @change="onParam3WeldingTypeChange">
								<view class="picker">
									{{selectedParam3WeldingType ? selectedParam3WeldingType.name : '请选择参数类型'}}
								</view>
							</picker>
						</view>
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">焊接模式:</view>
						<view class="param-picker-bg">
							<picker mode="selector" :range="param3WeldingModalList" range-key="name" @change="onParam3WeldingModal">
								<view class="picker">
									{{selectedParam3WeldingModal ? selectedParam3WeldingModal.name : '请选择模式'}}
								</view>
							</picker>
						</view>
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">焊接电流(A):</view>
						<input class="param-value-txt" type="digit" v-model="welding.electricity" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">焊接电压(V):</view>
						<input class="param-value-txt" type="digit" v-model="welding.voltage.value" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">电压一元修正值(%):</view>
						<input class="param-value-txt" type="digit" v-model="welding.voltage.correction" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">起弧延时时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="welding.arcStartOverTime" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">断弧重连:</view>
						<input class="param-value-txt" type="digit" v-model="welding.arcReconnect" />
					</view>
				</view>
				
				<view v-if="currentTabPosition==tabList[3].tabIndex">
					<view class="content-tab-title-bg">
						摆焊参数
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">启用摆焊:</view>
						<view class="param-value-cb-bg">
							<switch @change="isEnabledChange1" :checked="weave.isEnabled"></switch>
						</view>
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">摆动方式:</view>
						<view class="param-picker-bg">
							<picker mode="selector" :range="param4SwingWayList" range-key="name" @change="onParam4SwingWayChange">
								<view class="picker">
									{{selectedParam4SwingWay ? selectedParam4SwingWay.name : '请选择摆动方式'}}
								</view>
							</picker>
						</view>
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左摆幅度(mm):</view>
						<input class="param-value-txt" type="digit" v-model="weave.leftAmplitude" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">右摆幅度(mm):</view>
						<input class="param-value-txt" type="digit" v-model="weave.param4RightMm" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">摆动频率(Hz):</view>
						<input class="param-value-txt" type="digit" v-model="weave.frequency" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左停留时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="weave.leftDelay" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">右停留时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="weave.rightDelay" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左摆角度:</view>
						<input class="param-value-txt" type="digit" v-model="weave.leftAngle" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">右摆角度:</view>
						<input class="param-value-txt" type="digit" v-model="weave.rightAngle" />
					</view>
					<!-- <view class="param-item-bg">
						<view class="param-title-txt">停摆方式:</view>
						<view class="param-picker-bg">
							<picker mode="selector" :range="param4StopSwingWayList" range-key="name" @change="onParam4StopSwingWayChange">
								<view class="picker">
									{{selectedParam4StopSwingWay ? selectedParam4StopSwingWay.name : '请选择停摆方式'}}
								</view>
							</picker>
						</view>
					</view> -->
				</view>
				
				<view v-if="currentTabPosition==tabList[4].tabIndex">
					<view class="content-tab-title-bg">
						电弧跟踪参数
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">启用电弧跟踪:</view>
						<view class="param-value-cb-bg">
							<switch @change="isEnabledChange2" :checked="arcTracking.isEnabled"></switch>
						</view>
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左右跟踪功能:</view>
						<view class="param-value-cb-bg">
							<switch @change="leftRightTrackingEnabledChange" :checked="arcTracking.leftRightTrackingEnabled"></switch>
						</view>
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">分段纠偏周期(ms):</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.segmentCorrection" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左右跟踪增益:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.leftRightGain" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左右基准偏差:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.leftRightBaseDeviation" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左右最小补偿量:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.leftRightMinCompensation" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左右最大补偿量:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.leftRightMaxCompensation" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左右最大纠偏角度:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.leftRightMaxCorrectionAngle" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左右单次最大补偿量:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.leftRightMaxSingleCompensation" />
					</view>
					
					<view class="param-item-bg">
						<view class="param-title-txt">上下跟踪功能:</view>
						<view class="param-value-cb-bg">
							<switch @change="upDownTrackingEnabledChange" :checked="arcTracking.upDownTrackingEnabled"></switch>
						</view>
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">上下跟踪增益:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.upDownGain" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">上下基准偏差:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.upDownBaseDeviation" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">上下最小补偿量:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.upDownMinCompensation" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">上下最大补偿量:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.upDownMaxCompensation" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">上下引用采样计数:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.upDownReferenceSampleCount" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">上下最大纠偏角度:</view>
						<input class="param-value-txt" type="digit" v-model="arcTracking.upDownMaxCorrectionAngle" />
					</view>
				</view>
				
				<view v-if="currentTabPosition==tabList[5].tabIndex">
					<view class="content-tab-title-bg">
						运动参数
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">焊接速度(mm/s):</view>
						<input class="param-value-txt" type="digit" v-model="motion.weldingSpeed" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">寻位限速(mm/s):</view>
						<input class="param-value-txt" type="digit" v-model="motion.positioningSpeed" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">最大转速(RPM):</view>
						<input class="param-value-txt" type="digit" v-model="motion.maxSpeed" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">低通滤波(Hz):</view>
						<input class="param-value-txt" type="digit" v-model="motion.lowPassFilter" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">启用间断焊:</view>
						<view class="param-value-cb-bg">
							<switch @change="isEnabledChange3" :checked="motion.sectionWeldingEnabled"></switch>
						</view>
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">非间断焊速度(mm/s):</view>
						<input class="param-value-txt" type="digit" v-model="motion.unWeldSectionSpeed" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">间断焊长度(mm):</view>
						<input class="param-value-txt" type="digit" v-model="motion.weldSectionLength" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">非间断焊长度(mm):</view>
						<input class="param-value-txt" type="digit" v-model="motion.unWeldSectionLength" />
					</view>
				</view>
				
				<view v-if="currentTabPosition==tabList[6].tabIndex">
					<view class="content-tab-title-bg">
						再起弧参数
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">启用再起弧:</view>
						<view class="param-value-cb-bg">
							<switch @change="isEnabledChange4" :checked="arcRestart.isEnabled"></switch>
						</view>
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">再起弧次数:</view>
						<input class="param-value-txt" type="digit" v-model="arcRestart.restartCount" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">再起弧时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="arcRestart.restartInterval" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">再起弧抽丝时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="arcRestart.isEnabwireFeedDelayled" />
					</view>
				</view>
				
				<view v-if="currentTabPosition==tabList[7].tabIndex">
					<view class="content-tab-title-bg">
						拐角焊参数
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">焊接速度(mm/s):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWelding.weldingSpeed" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">最大转速(RPM):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWelding.maxSpeed" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">焊接电流(A):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWelding.electricity" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">焊接电压(V):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWelding.voltage" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">电压一元修正值(%):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWelding.voltageCorrection" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">拐角前距离(mm):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWelding.preCornerDistance" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">拐角后距离(mm):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWelding.postCornerDistance" />
					</view>
				</view>
				
				<view v-if="currentTabPosition==tabList[8].tabIndex">
					<view class="content-tab-title-bg">
						拐角工艺特定参数
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">启用摆焊:</view>
						<view class="param-value-cb-bg">
							<switch @change="param9StartChange" :checked="cornerWeave.isEnabled"></switch>
						</view>
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">摆动方式:</view>
						<view class="param-picker-bg">
							<picker mode="selector" :range="param9SwingWayList" range-key="name" @change="onParam9SwingWayChange">
								<view class="picker">
									{{selectedParam9SwingWay ? selectedParam9SwingWay.name : '请选择摆动方式'}}
								</view>
							</picker>
						</view>
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左摆幅度(mm):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWeave.leftAmplitude" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">右摆幅度(mm):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWeave.rightAmplitude" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">摆动频率(Hz):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWeave.frequency" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左停留时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWeave.leftDelay" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">右停留时间(ms):</view>
						<input class="param-value-txt" type="digit" v-model="cornerWeave.rightDelay" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">左摆角度:</view>
						<input class="param-value-txt" type="digit" v-model="cornerWeave.leftAngle" />
					</view>
					<view class="param-item-bg">
						<view class="param-title-txt">右摆角度:</view>
						<input class="param-value-txt" type="digit" v-model="cornerWeave.rightAngle" />
					</view>
					<!-- <view class="param-item-bg">
						<view class="param-title-txt">停摆方式:</view>
						<view class="param-picker-bg">
							<picker mode="selector" :range="param9StopSwingWayList" range-key="name" @change="onParam9StopSwingWayChange">								<view class="picker">
									{{selectedParam9StopSwingWay ? selectedParam9StopSwingWay.name : '请选择停摆方式'}}
								</view>
							</picker>
						</view>
					</view> -->
				</view>
				
			</scroll-view>
		</view>
		
		<view class="btn-bg">
			<view class="whole-width-bg">
				<view class="btn1-bg mar-right" @click="modifyAndAddProcess">{{isModifyProcess?'修改':'新增'}}</view>
				<view class="btn1-bg mar-left">保存</view>
			</view>
		</view>
	</view>
</template>

<script>
	import * as Constants from '@/common/constants.js';
	import robotApi from '../apis/robotApi';
	export default {
		name: "robot-process-edit",
		data() {
			return {
				tabList: [{
						name: "引弧",
						tabIndex: 0
					},
					{
						name: "收弧",
						tabIndex: 1
					},
					{
						name: "焊接",
						tabIndex: 2
					},
					{
						name: "摆焊",
						tabIndex: 3
					},
					{
						name: "电弧跟踪",
						tabIndex: 4
					},
					{
						name: "运动",
						tabIndex: 5
					},
					{
						name: "再起弧",
						tabIndex: 6
					},
					{
						name: "拐角焊参数",
						tabIndex: 7
					},
					{
						name: "拐角工艺参数",
						tabIndex: 8
					}
				],
				currentTabPosition: 0,
				
				proceeName: "",

				arcStart: {
					arcDuration: 0,
					electricity: 0,
					voltage: {
						value: 0,
						correction: 0,
					},
					gasDuration: 0,
					riseFall: 0
				},
				arcEnd: {
					arcDuration: 0,
					electricity: 0,
					voltage: {
						value: 0,
						correction: 0,
					},
					gasDuration: 0,
					riseFall: 0
				},

				welding: {
					mode: -1,
					electricityType: -1,
					electricity: 0,
					voltage: {
						value: 0,
						correction: 0,
					},
					arcStartOverTime: 0,
					arcReconnect: 0
				},
				param3WeldingTypeList: [
					{
						name: "一元模式",
						code: 0
					}
				],
				selectedParam3WeldingType: null,
				param3WeldingModalList: [
					{
						name: "直流",
						code: 0
					},
					{
						name: "脉冲",
						code: 1
					}
				],
				selectedParam3WeldingModal: null,

				weave: {
					isEnabled: true,
					type: -1,
					leftAmplitude: 0,
					param4RightMm: 0,
					frequency: 0,
					leftDelay: 0,
					rightDelay: 0,
					leftAngle: 0,
					rightAngle: 0
				},
				param4SwingWayList: [
					{
						name: "正弦摆动",
						code: 0
					}
				],
				selectedParam4SwingWay: null,
				// param4StopSwingWayList: [
				// 	{
				// 		name: "停止摆动",
				// 		code: 0
				// 	}
				// ],
				// selectedParam4StopSwingWay: null,
				
				arcTracking: {
					isEnabled: true,
					leftRightTrackingEnabled: true,
					segmentCorrection: 0,
					leftRightGain: 0,
					leftRightBaseDeviation: 0,
					leftRightMinCompensation: 0,
					leftRightMaxCompensation: 0,
					leftRightMaxCorrectionAngle: 0,
					leftRightMaxSingleCompensation: 0,
					upDownTrackingEnabled: true,
					upDownGain: 0,
					upDownBaseDeviation: 0,
					upDownMinCompensation: 0,
					upDownMaxCompensation: 0,
					upDownReferenceSampleCount: 0,
					upDownMaxCorrectionAngle: 0,
				},
				
				motion: {
					weldingSpeed: 0,
					positioningSpeed: 0,
					maxSpeed: 0,
					lowPassFilter: 0,
					sectionWeldingEnabled: false,
					unWeldSectionSpeed: 0,
					weldSectionLength: 0,
					unWeldSectionLength: 0
				},
				
				arcRestart: {
					isEnabled: true,
					restartCount: 0,
					restartInterval: 0,
					isEnabwireFeedDelayled: 0
				},
				
				cornerWelding: {
					weldingSpeed: 0,
					maxSpeed: 0,
					electricity: 0,
					voltage: 0,
					voltageCorrection: 0,
					preCornerDistance: 0,
					postCornerDistance: 0
				},
				
				cornerWeave: {
					isEnabled: true,
					weaveType: -1,
					leftAmplitude: 0,
					rightAmplitude: 0,
					frequency: 0,
					leftDelay: 0,
					rightDelay: 0,
					leftAngle: 0,
					rightAngle: 0,
				},
				param9SwingWayList: [
					{
						name: "正弦摆动",
						code: 0
					}
				],
				selectedParam9SwingWay: null,
				// param9StopSwingWayList: [
				// 	{
				// 		name: "停止摆动",
				// 		code: 0
				// 	}
				// ],
				// selectedParam9StopSwingWay: null,
				
				isModifyProcess: false,
				processDetailId: this.processNumber,
				showPageFrom: this.showCurrentPageFrom,
				
				isAddOrModifyProcess: false,
			};
		},
		props: {
			/**
			 * 显示当前组件的操作类型
			 */
			showCurrentPageFrom: {
				type: Number,
				default: 0
			},
			processNumber: {
				type: Number,
				default: -1
			}
		},
		mounted() {
			console.log("showCurrentPageFrom-->" + this.showCurrentPageFrom)
			console.log("processNumber>" + this.processNumber)
			console.log("processDetailId>" + this.processDetailId)
			this.selectedParam3WeldingType = this.param3WeldingTypeList[0]
			this.selectedParam3WeldingModal = this.param3WeldingModalList[0]
			
			this.selectedParam4SwingWay = this.param4SwingWayList[0]
			// this.selectedParam4StopSwingWay = this.param4StopSwingWayList[0]
			
			this.selectedParam9SwingWay = this.param9SwingWayList[0]
			// this.selectedParam9StopSwingWay = this.param9StopSwingWayList[0]
			
			if (this.showPageFrom == Constants.INDEX_SHOW_PROCESS_EDIT_FROM_PROCESS_LIST_MODIFY ||
				this.showPageFrom == Constants.INDEX_SHOW_PROCESS_EDIT_FROM_PROCESS_LIST_MODIFY_BY_TEACH_WELDING
			) {
				this.isModifyProcess = true
			}
			this.init()
			this.getDetail()
			
			let _this = this
			uni.$on("noticeIndexShowProcessEditViewFromProcessListView", function(data, index) {
				console.log("进行工艺编辑修改")
				_this.isModifyProcess = true
				_this.showPageFrom = Constants.INDEX_SHOW_PROCESS_EDIT_FROM_PROCESS_LIST_MODIFY
				_this.getDetail()
			})
			uni.$on("noticeIndexShowProcessEditViewFromProcessListViewRootTeachWelding", function(data, index) {
				console.log("示教焊接进行工艺编辑修改")
				_this.isModifyProcess = true
				_this.showPageFrom = Constants.INDEX_SHOW_PROCESS_EDIT_FROM_PROCESS_LIST_MODIFY_BY_TEACH_WELDING
				_this.getDetail()
			})
		},
		methods: {
			init() {
				this.arcStart = {
					arcDuration: 1000.0,
					electricity: 240.0,
					voltage: {
						value: 18.0,
						correction: -4.0,
					},
					gasDuration: 500.0,
					riseFall: 1000.0
				}
				
				this.arcEnd = {
					arcDuration: 800.0,
					electricity: 150.0,
					voltage: {
						value: 15.0,
						correction: -5.0,
					},
					gasDuration: 500.0,
					riseFall: 2000.0
				}
				
				this.welding = {
					mode: -1,
					electricityType: -1,
					electricity: 180.0,	
					voltage: {
						value: 18.0,
						correction: -2.0,
					},
					arcStartOverTime: 0.0,
					arcReconnect: 0.0
				}
				
				this.weave = {
					isEnabled: true,
					type: -1,
					leftAmplitude: 4.0,
					param4RightMm: 4.0,
					frequency: 1.2,
					leftDelay: 300.0,
					rightDelay: 300.0,
					leftAngle: 0.0,
					rightAngle: 0.0
				}
				
				this.arcTracking = {
					isEnabled: true,
					leftRightTrackingEnabled: true,
					segmentCorrection: 0.0,
					leftRightGain: 0.0,
					leftRightBaseDeviation: 0.0,
					leftRightMinCompensation: 0.0,
					leftRightMaxCompensation: 0.0,
					leftRightMaxCorrectionAngle: 0.0,
					leftRightMaxSingleCompensation: 0.0,
					upDownTrackingEnabled: true,
					upDownGain: 0.0,
					upDownBaseDeviation: 0.0,
					upDownMinCompensation: 0.0,
					upDownMaxCompensation: 0.0,
					upDownReferenceSampleCount: 0,
					upDownMaxCorrectionAngle: 0,
				}
				
				this.motion = {
					weldingSpeed: 2.3,
					positioningSpeed: 0.01,
					maxSpeed: 10.01,
					lowPassFilter: 1.0,
					sectionWeldingEnabled: false,
					unWeldSectionSpeed: 0,
					weldSectionLength: 0,
					unWeldSectionLength: 0
				}
				
				this.arcRestart = {
					isEnabled: true,
					restartCount: 3.0,
					restartInterval: 500.0,
					isEnabwireFeedDelayled: 100.0
				}
				
				this.cornerWelding = {
					weldingSpeed: 0.0,
					maxSpeed: 0.0,
					electricity: 0.0,
					voltage: 0.0,
					voltageCorrection: 0.0,
					preCornerDistance: 0.0,
					postCornerDistance: 0.0
				}
				
				this.cornerWeave = {
					isEnabled: true,
					weaveType: -1,
					leftAmplitude: 0.0,
					rightAmplitude: 0.0,
					frequency: 0.0,
					leftDelay: 0.0,
					rightDelay: 0.0,
					leftAngle: 0.0,
					rightAngle: 0.0,
				}
			},
			
			getDetail() {
				if (this.showPageFrom == Constants.INDEX_SHOW_PROCESS_EDIT_FROM_PROCESS_LIST_MODIFY ||
					this.showPageFrom == Constants.INDEX_SHOW_PROCESS_EDIT_FROM_PROCESS_LIST_MODIFY_BY_TEACH_WELDING
				) {
					robotApi.getProcessDetail(this.processDetailId)
						.then(res => {
							console.log("res -工艺详情->" + JSON.stringify(res))
							if (res) {
								this.proceeName = res.name
								this.arcStart = res.arcStart
								this.arcEnd = res.arcEnd
								this.welding = res.welding
								this.weave = res.weave
								this.arcTracking = res.arcTracking
								this.motion = res.motion
								this.arcRestart = res.arcRestart
								this.cornerWelding = res.cornerWelding
								this.cornerWeave = res.cornerWeave
								
								if (this.welding.mode >= 0 && this.welding.mode < this.param3WeldingTypeList.length) {
									this.selectedParam3WeldingType = this.param3WeldingTypeList[this.welding.mode]
								}
								if (this.welding.electricityType >= 0 && this.welding.electricityType < this.param3WeldingModalList.length) {
									this.selectedParam3WeldingModal = this.param3WeldingModalList[this.welding.electricityType]
								}
								if (this.weave.type >= 0 && this.weave.type < this.param4SwingWayList.length) {
									this.selectedParam4SwingWay = this.param4SwingWayList[this.weave.type]
								}
								if (this.cornerWeave.weaveType >= 0 && this.cornerWeave.weaveType < this.param9SwingWayList.length) {
									this.selectedParam9SwingWay = this.param9SwingWayList[this.cornerWeave.weaveType]
								}
							}
						})
				}
			},
			
			chooseTab(item, index) {
				if (this.currentTabPosition != item.tabIndex) {
					this.currentTabPosition = item.tabIndex
				}
			},
			
			onParam3WeldingTypeChange(e) {
				this.selectedParam3WeldingType = this.param3WeldingTypeList[e.detai.value]
			},
			onParam3WeldingModal(e) {
				this.selectedParam3WeldingModal = this.param3WeldingModalList[e.detail.value]
			},
			
			isEnabledChange1(e) {
				this.weave.isEnabled = e.detail.value
			},
			onParam4SwingWayChange(e) {
				this.selectedParam4SwingWay = this.param4SwingWayList[e.detai.value]
			},
			// onParam4StopSwingWayChange(e) {
			// 	this.selectedParam4StopSwingWay = this.param4StopSwingWayList[e.detai.value]
			// },
			
			isEnabledChange2(e) {
				this.arcTracking.isEnabled = e.detail.value
			},
			leftRightTrackingEnabledChange(e) {
				this.arcTracking.leftRightTrackingEnabled = e.detail.value
			},
			upDownTrackingEnabledChange(e) {
				this.arcTracking.upDownTrackingEnabled = e.detail.value
			},
			
			isEnabledChange3(e) {
				this.motion.sectionWeldingEnabled = e.detail.value
			},
			
			isEnabledChange4(e) {
				this.arcRestart.isEnabled = e.detail.value
			},
			
			param9StartChange(e) {
				this.cornerWeave.isEnabled = e.detail.value
			},
			onParam9SwingWayChange(e) {
				this.selectedParam9SwingWay = this.param9SwingWayList[e.detai.value]
			},
			// onParam9StopSwingWayChange(e) {
			// 	this.selectedParam9StopSwingWay = this.param9StopSwingWayList[e.detai.value]
			// },
			
			modifyAndAddProcess() {
				if (this.isModifyProcess) {
					if (this.showPageFrom == Constants.INDEX_SHOW_PROCESS_EDIT_FROM_PROCESS_LIST_MODIFY ||
						this.showPageFrom == Constants.INDEX_SHOW_PROCESS_EDIT_FROM_PROCESS_LIST_MODIFY_BY_TEACH_WELDING
					) {
						this.updateName()
					}
				} else {
					this.addConfirm()
				}
			},
			
			updateName() {
				let urlType = Constants.IN_PROCESS_LIST_VIEW_FROM_HAND_TEMPLATE_VIEW
				if (this.showPageFrom == Constants.INDEX_SHOW_PROCESS_EDIT_FROM_PROCESS_LIST_MODIFY_BY_TEACH_WELDING) {
					urlType = Constants.IN_PROCESS_LIST_VIEW_FROM_TEACH_TEMPLATE_VIEW
				}
				let list = []
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				if (this.isAddOrModifyProcess) {
					return
				}
				this.isAddOrModifyProcess = true
				robotApi.updateProcessName(this.processDetailId, JSON.stringify(this.proceeName))
					.then(res => {
						console.log(typeof(res))
						if (typeof(res) === 'boolean' && res) {
							
							list.push(1)
							this.modifySuccess()
						}
					})
				robotApi.updateArcStartParam(this.processDetailId, JSON.stringify(this.arcStart))
					.then(res => {
						console.log(typeof(res))
						if (typeof(res) === 'boolean' && res) {
							
							list.push(2)
							this.modifySuccess()
						}
					})
				robotApi.updateArcEndParam(this.processDetailId, JSON.stringify(this.arcEnd))
					.then(res => {
						console.log(typeof(res))
						if (typeof(res) === 'boolean' && res) {
							
							list.push(3)
							this.modifySuccess()
						}
					})
				this.welding.mode = this.selectedParam3WeldingType.code
				this.welding.electricityType = this.selectedParam3WeldingModal.code
				robotApi.updateWeldingParam(this.processDetailId, JSON.stringify(this.welding))
					.then(res => {
						console.log(typeof(res))
						if (typeof(res) === 'boolean' && res) {
							
							list.push(4)
							this.modifySuccess()
						}
					})
				this.weave.type = this.selectedParam4SwingWay.code
				robotApi.updateWeaveParam(this.processDetailId, JSON.stringify(this.weave))
					.then(res => {
						console.log(typeof(res))
						if (typeof(res) === 'boolean' && res) {
							
							list.push(5)
							this.modifySuccess()
						}
					})
				robotApi.updateArcTrackingParam(this.processDetailId, JSON.stringify(this.arcTracking))
					.then(res => {
						console.log(typeof(res))
						if (typeof(res) === 'boolean' && res) {
							
							list.push(6)
							this.modifySuccess()
						}
					})
				robotApi.updateMotionParam(this.processDetailId, JSON.stringify(this.motion))
					.then(res => {
						console.log(typeof(res))
						if (typeof(res) === 'boolean' && res) {
							
							list.push(7)
							this.modifySuccess()
						}
					})
				robotApi.updateArcRestartParam(this.processDetailId, JSON.stringify(this.arcRestart))
					.then(res => {
						console.log(typeof(res))
						if (typeof(res) === 'boolean' && res) {
							
							list.push(8)
							this.modifySuccess()
						}
					})
				robotApi.updateCornerWeldingParam(this.processDetailId, JSON.stringify(this.cornerWelding))
					.then(res => {
						console.log(typeof(res))
						if (typeof(res) === 'boolean' && res) {
							
							list.push(9)
							this.modifySuccess()
						}
					})
				this.cornerWeave.weaveType = this.selectedParam9SwingWay.code
				robotApi.updateCornerWeaveParam(this.processDetailId, JSON.stringify(this.cornerWeave))
					.then(res => {
						console.log(typeof(res))
						if (typeof(res) === 'boolean' && res) {
							
							list.push(10)
							
						}
					})
				setTimeout(function(){
					uni.hideLoading()
					this.isAddOrModifyProcess = false
					if (list.length == 10) {
						uni.navigateTo({
							url: "/pages/robot/processTemplate?toProcessListFromPage=" + urlType
						})
					}
				}, 2000)
			},
			modifySuccess(list) {
				
			},
			
			addConfirm() {
				if (!this.proceeName || this.proceeName== "") {
					uni.showToast({
						title: "请输入工艺名称"
					})
					return
				}
				let data = {
					name: this.proceeName,
				}
				data.arcStart = this.arcStart
				data.arcEnd = this.arcEnd
				this.welding.mode = this.selectedParam3WeldingType.code
				this.welding.electricityType = this.selectedParam3WeldingModal.code
				data.welding = this.welding
				this.weave.type = this.selectedParam4SwingWay.code
				data.weave = this.weave
				data.arcTracking = this.arcTracking
				data.motion = this.motion
				data.arcRestart = this.arcRestart
				data.cornerWelding = this.cornerWelding
				this.cornerWeave.weaveType = this.selectedParam9SwingWay.code
				data.cornerWeave = this.cornerWeave
				
				if (this.isAddOrModifyProcess) {
					return
				}
				this.isAddOrModifyProcess = true
				robotApi.addProcess(data)
					.then(res => {
						this.isAddOrModifyProcess = false
						console.log("新增工艺成功：" + JSON.stringify(res) + " ")
						console.log(typeof(res))
						if (parseInt(res) > 0) {
							let sendParam = {
								processName: this.proceeName,
								processId: res
							}
							this.notifyIndexChangeView(sendParam)
						} else {
							uni.showToast({
								title: "新增工艺失败",
								position: "bottom"
							})
						}
					})
					.catch(erro => {
						this.isAddOrModifyProcess = false
					})
			},

			/**
			 * 通知首页是否需要切换页面
			 * 		如果当前组件是因为：
			 * 			手动模版组件中点击工艺定制触发index切换到当前组件，则新增成功后需要通知index切换到手动模版组件并将数据带给手动模版组件中
			 * @param sendParam 需要带给手动模版的数据：工艺名称和新增成功接口返回的工艺号ID
			 */
			notifyIndexChangeView(sendParam) {
				if (this.showPageFrom == Constants.INDEX_SHOW_PROCESS_EDIT_FROM_HAND_TEMPLATE) {
					/*
						首页在手动模板，选择定制工艺（
							会在手动模板子组件通知并传参给父组件index，让父组件在切换显示工艺编辑子组件时带上传过来的参数
						）
					*/
				   this.$emit("notifyIndexShowHandTemSonView", Constants.INDEX_SHOW_HAND_TEMPALTE_FROM_PROCESS_EDIT, sendParam)
				} else if (this.showPageFrom == Constants.INDEX_SHOW_PROCESS_EDIT_FROM_TEACH_TEMPLATE) {
					/*
						首页在示教模板，选择定制工艺（
							会在示教模板子组件通知并传参给父组件index，让父组件在切换显示工艺编辑子组件时带上传过来的参数
						）
					*/
				   this.$emit("notifyIndexShowTeachTemSonView", Constants.INDEX_SHOW_HAND_TEMPALTE_FROM_PROCESS_EDIT, sendParam)
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.process-edit-bg {
		padding: 20rpx;
	}

	.process-num-bg {
		display: flex;
		align-items: center;
	}

	.title-txt {
		min-width: 200rpx;
		color: #FFFFff;
		font-size: 28rpx;
	}

	.num-txt {
		color: #FFFFff;
		font-size: 32rpx;
		border: 2rpx solid rgba(59, 95, 159, 1);
		padding: 20rpx;
		border-radius: 16rpx;
		flex: 1;
	}

	.param-set-bg {
		display: flex;
		padding-bottom: 100px;
	}

	.tab-bg {
		display: flex;
		align-items: center;
		flex-direction: column;
		height: 980rpx;
		padding-top: 20rpx;
		margin-right: 20rpx;
		box-sizing: border-box;
		width: 50rpx;
	}

	.tab-item-selected-bg {
		padding: 16rpx 10rpx 16rpx 0;
		width: 40rpx;
		border-right: 2rpx solid rgba(59, 130, 246, 1);
		color: #FFFFFF;
		font-size: 36rpx;
	}

	.tab-item-unselect-bg {
		padding: 16rpx 10rpx 16rpx 0;
		width: 40rpx;
		color: rgba(148, 163, 184, 1);
		font-size: 30rpx;
	}

	.content-edit-bg {
		padding-top: 40rpx;
		height: 980rpx;
	}

	.content-tab-title-bg {
		color: #FFFFFF;
		font-size: 36rpx;
		margin-bottom: 20rpx;
	}

	.param-item-bg {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.param-title-txt {
		width: 300rpx;
		color: #FFFFff;
		font-size: 28rpx;
	}

	.param-value-txt {
		color: #FFFFff;
		font-size: 32rpx;
		border: 2rpx solid rgba(59, 95, 159, 1);
		padding: 20rpx;
		border-radius: 16rpx;
		flex: 1;
		text-align: right;
	}

	.param-picker-bg {
		flex: 1;

		input,
		.picker {
			// /* width: 100%; */
			flex: 1;
			padding: 10px;
			border: 1px solid rgba(59, 95, 159, 1);
			border-radius: 6px;
			font-size: 16px;
			background-color: #1e40af;
			color: #FFFFFF;
			text-align: right;
		}
	}
	
	.param-value-cb-bg {
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}
	
	.btn-bg {
		position: fixed;
		bottom: 0;
		right: 0;
		left: 0;
		padding: 0 20px 20px;
		background-color: #1e40af;
		display: flex;
		justify-content: center;
		align-items: center;
		z-index: 90;
	}
	.whole-width-bg {
		display: flex;
		align-items: center;
		width: 100%;
	}
	.btn1-bg {
		padding: 20rpx 0;
		flex: 1;
		border-radius: 16rpx;
		background-color: #3b82f6;
		color: #FFFFFF;
		text-align: center;
	}
	.mar-left {
		margin-left: 20rpx;
	}
	.mar-right {
		margin-right: 20rpx;
	}
</style>